// pages/user/userCharge/charge/charge.js
var sign = require("../../../../utils/lib/sign.js")
var app = getApp();
import tempObj from '../../../template/BottomTab.js'
var a = tempObj.changeColor
Page({
  changeColor: a,
  /**
   * 页面的初始数据
   */
  data: {
    tabBars: {
      left: {
        url: '../../../resume/list/list',
        icon: '../../../img/aunt.png',
        text: "优秀阿姨推荐",

      },
      right: {
        url: '../../../user/index/index',
        icon: '../../../img/mine.png',
        text: "我的",

      },
    },
    dataSrc:[],
    mobile: "",
    cardMoeny: 0,
    cardId:0
  },
    

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      "tabBars.currentIndex": app.globalData.currentIndex
    })
    var cardMoney = options.cardValue;
    var cardId = options.id;
    var mobile = wx.getStorageSync('mobile');

    var dataSrc1000 = [
      '../../../img/1.png', '../../../img/2.png', '../../../img/3.png', '../../../img/4.png', '../../../img/5.png',
    ];
    var dataSrc2000 = [
      '../../../img/6.png', '../../../img/7.png', '../../../img/8.png', '../../../img/9.png', '../../../img/10.png', '../../../img/11-youhuiquan.png', '../../../img/25.png', '../../../img/26.png', '../../../img/27.png', '../../../img/28.png', '../../../img/29.png',
    ];
    var dataSrc3000 = [
      '../../../img/12.png', '../../../img/13.png', '../../../img/14.png', '../../../img/15.png', '../../../img/16.png', '../../../img/17.png', '../../../img/18.png', '../../../img/19.png', '../../../img/20.png', '../../../img/21.png', '../../../img/22.png',
    ];
    var img = [];
    if (cardMoney==1000){
      img = dataSrc1000;
    }
    if (cardMoney == 2000) {
      img = dataSrc2000;
    }
    if (cardMoney == 3000) {
      img = dataSrc3000;
    }

    this.setData({
      mobile:mobile,
      cardMoney:cardMoney,
      cardId:cardId,
      dataSrc:img
    })
  
  },
 
  saveCard:function(e){
    // var userId = wx.getStorageSync("userId");
    // var mobile = wx.getStorageSync("mobile");
    var userId = "11383";
    var mobile = "15201023689";
    var cardType = e.detail.value.cardId;
    var referee = e.detail.value.staffCode;
    var params = {
      userId: userId,
      mobile: mobile,
      cardType: cardType,
      payType: 2,
      referee: referee
    }
    params = sign.getSignParams(params)
    // wx.request({
    //   url: app.globalData.baseUrl + '/api/user/card/save.json',
    //   data: params,
    //   header: {
    //     "Content-Type": "application/x-www-form-urlencoded"
    //   },
    //   method: 'POST',
    //   success: function(res) {
    //     var result = res.data;
    //     if(result.status==0){
    //       wx.requestPayment({
    //         timeStamp: timeStamp,
    //         nonceStr: nonceStr,
    //         "package": orderNo,
    //         signType: 'MD5',
    //         paySign: sign,
    //         success: function(res) {
    //           wx.showToast({
    //             title: '支付成功',
    //           })
    //         },
    //         fail: function(res) {
    //           debugger
    //           wx.showToast({
    //             title: '支付失败',
    //           })
    //         },
    //       })
    //     }else{
          
    //     }
    //   },
    //   fail: function(res) {
        
    //   }
    // })
  }
})